Javascript libs: Dojo 'v' Ext 'v' jQuery 'v' YUI

Ron Savage on 2008-10-24T08:16:33

Since we all think differently (at least to some degree) in the same way that we have different tastebuds etc, there cannot be one Javascript library which suits every user.

So, when I say I prefer Yahoo's User Interface (YUI) library, I don't intend that everyone should adopt it, only that of the ones I tried, it's far and away my favourite.

As a test, I wrote the same code using each of these libraries (except jQuery), and here I report my experiences.

o The Dojo Toolkit at http://dojotoolkit.org/

To start with, Dojo looked promising, but as with Ext I soon found the documentation inadequate, and I wasn't really doing anything sophisticated.

Comments by other users on their forum helped significantly, but I immediately felt that if every step was going to require scanning many posting to see how to actually do anything, progress would be painfully slow.

So, exit Dojo.

o Ext JS at http://extjs.com

A lot of Ext is set up with data structures, what Javascript calls object literals.

It's a very elegant way of doing things, but there's a catch.

To process these structures, your page needs to include 575,000 bytes of Javascript, for that's the combined size of the Ext libs.

This Javascript can be thought of as a code generator, in the sense that it processes the object literals and turns them into executable code.

Of course, the ideal situation is that you send all that to the web client as infrequently as possible, and thereafter you use Ajax to do the work.

Their web site does offer a way of building a customized set of features, which would have to be repeated each time you incorporate new features into the set you are using.

The major disappointment for me was that as soon as I wanted to do something not involving a default, I found the documentation often very superficial.

As with Dojo, I found useful comments from other users' feedback, but they had had to scan the source code to determine what was possible, and how to do it.

Lastly, the docs are confusing in suggesting what files to include in your web page, since one of the file names mentioned exists in 2 versions in the distro, and the docs don't tell you which one to use. A quick test using one failed, where the other succeeded, but it was another, albeit small, black mark against Ext.

But, this is all too much like hard work, so ... exit Ext.

o jQuery at http://jquery.com/

jQuery is based on the assumption you like endless method chaining. If you don't, too bad.

It's a specific way of designing syntax which allegedly matches the way we think.

As it happens, that for me is a huge turn-off, so look elsewhere for a review.

As an aside: There is a beautiful Perl module called accessors, which comes in 2 versions, with and without method chaining. Obviously I use the latter.

o YUI at http://developer.yahoo.com/yui/

Now, this one I like.

It can be included file by file, depending on the features you want, or you can use the YUI Dependency Configurator to get a customised set of files.

A major plus for me was the extensive documentation, which spells out many examples in a way which shows how simple code can be progressively extended.

Using YUI I've been able to produce a beautiful application, although as I indicated above, I assume experts in the other Javascript libraries could have done the same.

What matters to me, and indeed to each of us, is that we feel comfortable with our chosen tools, and for me YUI is the best. YMMV.

One last comment: the Perl module JSON::XS is highly recommended because it provides an extremely neat and simple way of converting a Perl data structure into exactly the format your Javascript code can gobble up and utilize, e.g. as part of an Ajax transaction.


Check out Joose

fansipans on 2008-10-24T12:00:54

Check out Joose too.

It's unlike the three in your post in that it's purely an object system for JavaScript, and an incredibly flexible one at that. It can work in conjunction with the interface tools provided by jQuery, YUI, etc., and I've found it quite helpful for maintaining any serious kind of state or logic client-side.

Re:Check out Joose

Ron Savage on 2008-10-25T23:54:29

I tried, but their web site does not respond.

Exit Joose.

But wait, there's more!

renodino on 2008-10-24T15:32:45

Have you tried MooTools ? I've seen some pretty nifty GUIs developed on it, and it seems pretty compact.

For a more professional solution (wo/ nasty Flash-ness), you might look into TIBCO GI, tho it has some of the same bloatware issues as ExtJS

I agree Dojo's docs to date have been appallingly bad...but now there are several print books on it (I haven't read any yet, but its on my TO DO list).

And I also agree YUI is probably the most accessible of all, probably because the website has really nice examples to play with. I hope Yahoo's current troubles don't lead to YUI's demise. A couple others you might try out:

Conspicuously absent from your list: Prototype/Scriptaculous ? Plus there's a GWT-ish Perl library for it: IWL

Re:But wait, there's more!

Ron Savage on 2008-10-26T00:38:52

No response from the MooTools link.

Exit MooTools.

ThinWire: I abstain from Java, and am only looking for Javascript stuff. Now, in the ThinWire FAQ I see
'Thinwire is not designed to use custom JavaScript code elsewhere'. Oh. (By 'elsewhere' I assume they mean 'anywhere').

Exit ThinWire.

Now: QooXDoo.

Yes, this is more suited to my way of thinking, and a demo like this (go in, I'm afraid, via Documentation/Getting started/Snippets/Demo browser):
http://demo.qooxdoo.org/current/demobrowser/#widget~TabView.html
gives a good indication of how to work the levers.

I wouldn't switch now, but this makes me think QooXdoo is almost a plausible alternative to YUI :-).

$many x $thanx;

As for 'Conspicuously absent from your list'! I didn't claim to review all libs, or even review broadly...

Looks like you'd be better off doing that than me.

And as soon as you say bloatware, I'm turned off, so thanx for that, too.

Lastly, months ago I did look at Prototype/Scriptaculous, but didn't like to look of them, and as I've emphasized, these judgments are very personal, and so, having found a package (YUI) I'm happy with, I'd need a very strong argument to investigate them in enough depth to consider switching.

jQuery

perrin on 2008-10-24T15:57:26

I don't like method chaining either, but you can program jQuery without it. It's so much easier to use than YUI. I think you should give it a chance.

Re:jQuery

Ron Savage on 2008-10-26T00:11:30

The phraseology I used implied it was just the chaining that I don't like (true) but the other thing which put me off was the sheer quantity of code (in the demos, admittedly) to achieve results.

It reminded me of assembler (shudder) and Tk (mega-shudder). A lot of code for a small effect.

I, like you, and like everyone, either are forced to use a particular package in a specific situation, or choose something we like. And this I don't like.

OK. I've had another looks at jQuery's docs, specifically the Tab interface.

I find the examples /very/ terse and fragmentary, so the YUI docs win hands-down.

Rico/Prototype

benhitz on 2008-10-24T16:50:01

I was really happy with Rico (http://www.openrico.org), which is built on prototype. However, I really only had a single application - which was a dynamic AJAX table with sorting and filtering.

There is not much of a perl API. I did end up reimplementing it (just a quick database connection).

Re:Rico/Prototype

Ron Savage on 2008-10-25T23:56:52

The home page of OpenRico responds, but clicking on Demo gets no response.

And from their archives, it looks like development stopped in Jan 2008 :-(.

Exit OpenRico.

loving jquery

markjugg on 2008-10-28T02:40:57

I've been using jQuery and love it. I find coding with it clear is simple, there are plenty of plugins and great docs online.

It's also been easy to write our own jQuery plugins.

Sometimes I use method chaining with it, but often I don't. I have found it useful at times and appreciate the feature.